package com.firefoxking.mysite.service.user.impl;

import com.firefoxking.mysite.dao.UserMapper;
import com.firefoxking.mysite.entity.User;
import com.firefoxking.mysite.service.user.UserService;
import com.firefoxking.mysite.utils.TaleUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public int addUser(User user) {
        return userMapper.addUser(user);
    }

    @Override
    public int deleteUser(Integer uid) {
        return userMapper.deleteUser(uid);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public User getUserById(Integer uid) {
        return userMapper.getUserById(uid);
    }

    @Override
    public User login(String username, String password) {
        password = TaleUtils.MD5encode(username + password);
        return userMapper.getUserByCond(username, password);
    }
}
